//$Id$
/*
 * Copyright (C) 2008-2009 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package org.apelikecoder.bulgariankeyboard;

import android.content.Context;

public abstract class BulgarianKeyboardBase extends LatinKeyboard {
	
    @Override
    public String getKbdName() {
		return "Bulgarian/" + getSubName();
	}
    
    abstract String getSubName();
	
    final static char cyr_a            = '\u0430';
    final static char cyr_b            = '\u0431';
    final static char cyr_v            = '\u0432';
    final static char cyr_g            = '\u0433';
    final static char cyr_d            = '\u0434';
    final static char cyr_e            = '\u0435';
    final static char cyr_zhe          = '\u0436';
    final static char cyr_ze           = '\u0437';
    final static char cyr_i            = '\u0438';
    final static char cyr_short_i      = '\u0439';
    final static char cyr_k            = '\u043a';
    final static char cyr_l            = '\u043b';
    final static char cyr_m            = '\u043c';
    final static char cyr_n            = '\u043d';
    final static char cyr_o            = '\u043e';
    final static char cyr_p            = '\u043f';
    final static char cyr_r            = '\u0440';
    final static char cyr_s            = '\u0441';
    final static char cyr_t            = '\u0442';
    final static char cyr_u            = '\u0443';
    final static char cyr_ef           = '\u0444';
    final static char cyr_ha           = '\u0445';
    final static char cyr_tse          = '\u0446';
    final static char cyr_cha          = '\u0447';
    final static char cyr_sha          = '\u0448';
    final static char cyr_shcha        = '\u0449';
    final static char cyr_hard_sign    = '\u044a';
    final static char cyr_ya           = '\u044f';
    final static char cyr_soft_sign    = '\u044c';
    final static char cyr_yu           = '\u044e';

    public BulgarianKeyboardBase(Context context, int xmlLayoutResId) {
        super(context, xmlLayoutResId);
    }

    public BulgarianKeyboardBase(Context context, int xmlLayoutResId, int mode) {
        super(context, xmlLayoutResId, mode);
    }

    @Override
    public boolean isEdible( int keyCode) {
        return "[]".contains(String.valueOf((char)keyCode));
    }

    @Override
    abstract public char getMappedKeyCode(int keyCode);
    
    @Override
    public char getComposed(char char1, char char2) {
        char res = 0;
        if (char2 == cyr_ha && char1 == cyr_s) {
            res = cyr_sha;
        } else if (char2 == cyr_t && char1 == cyr_sha) {
            res = cyr_shcha;
        } else if (char2 == cyr_u && char1 == cyr_hard_sign) {
            res = cyr_yu;
        } else if (char2 == cyr_ha && char1 == cyr_tse) {
            res = cyr_cha;
        }
        return res;
    }

    @Override
    public String toString() {
        return getKbdName();
    }
}
// vim:ts=4:sw=4:expandtab
